package com.ymatou.iapi.trading.ordersync.testcase;

import java.math.BigDecimal;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.trading.operate.parameter.PlaceOrderResp;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderService;
import com.ymatou.iapi.trading.operate.parameter.req.ApplySalesRefundRequestBean;
import com.ymatou.iapi.trading.ordersync.parameter.OrderBean;
import com.ymatou.iapi.trading.ordersync.service.SyncVerifyService;
import com.ymatou.iapi.trading.ordersync.service.SyncVerifyService;
import com.ymt.base.YmatouEasyCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;

/**
 * 同步指令接口 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_SyncOrderTrading {

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("同步指令接口");
	}

	@Before
	public void caseUp() {

	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(null);
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_SyncOrderTrading_001() {
		Logger.start(true, "交易下单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_002() {
		Logger.start(true, "订单支付,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_003() {
		Logger.start(true, "订单付款之前取消订单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			//取消订单
			orderCallService.cancelOrder(orderId, userId);

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_004() {
		Logger.start(true, "订单付款之后取消订单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//取消订单
			orderCallService.cancelOrder(orderId, userId);

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_SyncOrderTrading_005() {
		Logger.start(true, "修改收货人地址,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			//发货
			orderCallService.dispatched(orderId, sellerId);

			//修改地址
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			OrderBean order = new OrderBean();
			String orderJson = "{\"OrderId\":"
					+ orderId
					+ ",\"UserId\":"
					+ userId
					+ ",\"Address\":\"南京路步行街\",\"PostCode\":\"986574\",\"ReceievePerson\":\"洋码头\",\"Phone\":\"13200000005\",\"Telephone\":\"021-51025140\",\"QQ\":\"100001\",\"Email\":\"Hj02QUQuEXmk@sohu.com\",\"UserType\":\"Normal\",\"ChangeTime\":\"2016-12-26 10:57:26\"}";
			YmatouEasyCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/Buyer/ChangeOrderAddress");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_SyncOrderTrading_006() {
		Logger.start(true, "删除订单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);

			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//删除订单
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			OrderBean order = new OrderBean();
			String orderJson = "{\"orderId\":" + orderId
					+ ",\"isDelete\":true,\"userId\":" + userId + "}";
			YmatouEasyCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/Buyer/markOrderDeleted");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_SyncOrderTrading_007() {
		Logger.start(true, "CHANGE_DISCOUNT指令调用成功,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			//调整订单折扣
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			OrderBean order = new OrderBean();
			String orderJson = "{\"OrderId\":" + orderId + ",\"SellerId\":"
					+ sellerId
					+ ",\"Discount\":4,\"Freight\":5,\"DiscountTime\":\""
					+ YMTDateUtil.getSysTime() + "\"}";
			YmatouEasyCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/Seller/ChangeOrderDiscount");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_008() {
		Logger.start(true, "商家接单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_009() {
		Logger.start(true, "商家发货,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			//发货
			orderCallService.dispatched(orderId, sellerId);

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_010() {
		Logger.start(true, "清关,验证同步Mongo,ES数据");
		try {
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			//保存物流信息
			String billCode = SyncVerifyService.saveDeliverSummary(orderId,
					sellerId);

			//发货
			orderCallService.dispatched(orderId, sellerId);

			//同步国内发货信息
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			OrderBean order = new OrderBean();
			String orderJson = "{\"logisticsNos\":[\"" + billCode + "\"]}";
			YmatouEasyCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/Notify/SyncOrderLogisticStatus");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_011() {
		Logger.start(true, "国内发货,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			//同步国内发货信息
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			OrderBean order = new OrderBean();
			String orderJson = "{\"OrderId\":"
					+ orderId
					+ ",\"LogisticsNo\":\"autotest_123456\",\"Weight\":2,\"LogisticsCompany\":\"码头自动化测试物流\"}";
			YmatouEasyCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/Notify/SyncDomesticDeliveredInfo");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_012() {
		Logger.start(true, "发货回退到待发货状态,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			// 码头保存物流单号
			SyncVerifyService.saveDeliverSummary(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			//同步国内发货信息
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			OrderBean order = new OrderBean();
			String orderJson = "{\"orderId\":"
					+ orderId
					+ ",\"operateUser\":\"autotest\",\"reason\":\"autotest rollbac\"}";
			YmatouEasyCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/Common/RollbackToWaitDelivery");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_013() {
		Logger.start(true, "订单评价,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			//评价
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			OrderBean order = new OrderBean();
			String orderJson = "{\"orderId\":" + orderId + ",\"cancle\":false}";
			YmatouEasyCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/Buyer/markOrderEvaluated");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_014() {
		Logger.start(true, "用户延迟收货时间,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			//发货
			orderCallService.dispatched(orderId, sellerId);

			//延长收货
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			OrderBean order = new OrderBean();
			String orderJson = "{\"OrderId\":"
					+ orderId
					+ ",\"OperateUserId\":"
					+ userId
					+ ",\"DelayDay\":1,\"Remark\":\"自动化测试延长信息\",\"OperateUserType\":0}";
			YmatouEasyCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/Common/DelayReceive");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_015() {
		Logger.start(true, "确认收货,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			//发货
			orderCallService.dispatched(orderId, sellerId);

			//确认收货
			orderCallService.confirmReceive(userId, orderId);

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_016() {
		Logger.start(true, "修改身份证号码,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			//订单通知修改地址
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			OrderBean order = new OrderBean();
			String orderJson = "{\"orderId\":" + orderId
					+ ",\"businessType\":15}";
			YmatouEasyCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/Notify/OrderAsyncNotify");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_017() {
		Logger.start(true, "新用户新买手下单,,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//订单支付异步响应通知信息
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			OrderBean order = new OrderBean();
			String orderJson = "{\"orderId\":" + orderId + "}";
			YmatouEasyCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/trading/onOrderPaid");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_018() {
		Logger.start(true, "风控,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//订单支付风控系统通知
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			OrderBean order = new OrderBean();
			/*			风控检测未通过：{OrderId:105414523,ParamExt:{"Status":"rejected"}}
						风控检测通过：{OrderId:105414517,ParamExt:{"Status":"pass"}}
						风控检测失败：{OrderId:111111,ParamExt:{"Status":"auditing"}}*/
			String orderJson = "{\"orderId\":" + orderId
					+ ",\"ParamExt\":{\"Status\":\"rejected\"}}";
			YmatouEasyCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/Notify/RiskControlNotify");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_019() {
		Logger.start(true, "订单备注,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//修改订单note
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			OrderBean order = new OrderBean();

			String orderJson = "{\"OrderId\":"
					+ orderId
					+ ",\"UserId\":"
					+ userId
					+ ",\"RemarkContent\":\"修改订单备注01\",\"RemarkLevel\":1,\"RemarkTime\":\"2016-12-26 15:53:01\"}";
			YmatouEasyCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/Seller/ChangeOrderNote");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_020() {
		Logger.start(true, "申请退款,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			//申请退款
			orderCallService.applySalesRefundRequestInJava(orderId);

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_021() {
		Logger.start(true, "修改退款申请单,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			// 申请退款
			String refundBillNo = orderCallService
					.applySalesRefundRequestInJava(orderId)
					.getSalesRefundInfoList().get(0).getRefundBillNo();

			//修改退款申请单
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			OrderBean order = new OrderBean();

			String orderJson = "{\"OrderId\":"
					+ orderId
					+ ",\"RefundBillNo\":"
					+ refundBillNo
					+ ",\"RefundAmount\":473.00,\"RefundProductNum\":100,\"Reason\":\"123456789\",\"RefundType\":1}";

			YmatouEasyCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/SalesRefund/ChangeSalesRefundInfo");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_022() {
		Logger.start(true, "拒绝退款,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			//申请退款
			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJava(orderId);

			//拒绝退款
			orderCallService
					.salesrefundfailrequest(applySalesRefundRequestBean);

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_023() {
		Logger.start(true, "退款成功,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			//申请退款
			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJava(orderId);

			//退款成功
			orderCallService
					.salesrefundsuccessrequest(applySalesRefundRequestBean);

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_024() {
		Logger.start(true, "全都退款后取消订单,验证数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			OrderCallService orderCallService = new OrderCallService();

			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			//申请退款
			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJava(orderId);

			//退款成功
			orderCallService
					.salesrefundsuccessrequest(applySalesRefundRequestBean);

			Thread.sleep(3000);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_025() {
		Logger.start(true, "投诉维权,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			//订单投诉维权
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			OrderBean order = new OrderBean();
			String orderJson = "{\"OrderId\":" + orderId
					+ ",\"IsFrozen\":true,\"UserId\":" + sellerId + "}";
			YmatouEasyCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/Common/FrozenOrUnFrozen");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_026() {
		Logger.start(true, "修改物流单号,指令调用成功,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();
			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			//订单投诉维权
			YmatouEasyCall YmatouEasyCall = new YmatouEasyCall("", "POST",
					"JSON");
			OrderBean order = new OrderBean();
			String orderJson = "{\"SellerId\":" + sellerId + ",\"OrderId\":"
					+ orderId + ",\"BillCodeList\":\""
					+ TestDataManager.randomStr(10) + "\"}";
			YmatouEasyCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/Seller/ChangeOrderDeliveryNumber");
			YmatouEasyCall.setData(orderJson);
			YmatouEasyCall.callService();

			if (SyncVerifyService.getSyncResult(orderId)) {

				SyncVerifyService.verify(orderId, userId, sellerId);
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SyncOrderTrading_027() {
		Logger.start(true, "确认收货之后退款成功,验证同步Mongo,ES数据");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrder = PlaceOrderService.placeOrder3();

			int userId = placeOrder.getUserId();
			int sellerId = placeOrder.getOrderList().get(0).getSellerId();

			int tradingId = placeOrder.getTradingId();
			Integer orderId = placeOrder.getOrderList().get(0).getOrderId();
			Logger.comment("前置数据准备结束");

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			//接单
			orderCallService.acceptOrder(orderId, sellerId);

			orderCallService.confirmReceive(userId, orderId);

			//申请退款
			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJava(orderId);

			//退款成功
			orderCallService
					.salesrefundsuccessrequest(applySalesRefundRequestBean);

			SyncVerifyService.getSyncResult(orderId);

			SyncVerifyService.verify(orderId, userId, sellerId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}